package com.egao.orderB.biz.impl;

import com.egao.common.core.damon.results.BaseDao;
import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.damon.utils.Utils;
import com.egao.common.core.web.JsonResult;
import com.egao.common.system.entity.User;
import com.egao.orderB.biz.BillExamineBiz;
import com.egao.orderB.entity.Bill;
import com.egao.orderB.entity.BillExamine;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 * 数据层实现类
 * @author : Doman
 * @date : 2021-04-13 10:40:47
 * @version ：1.0
 */
@Repository
public class BillExamineBizImpl extends BaseDao implements BillExamineBiz {

	@Override
	public JsonResult list(PageResult2<T> page, BillExamine billExamine, User loginUser) throws Exception {
		Map<String, String> map  = new HashMap<String, String>();
		RowMapper<BillExamine> rm = new BeanPropertyRowMapper<BillExamine>(BillExamine.class);
		StringBuffer sql = new StringBuffer("select b.id,b.organization_id,b.bill_id,b.oceanId");
        sql.append(",b.customer_id,b.customer,b.contacts,b.contacts_phone");
		sql.append(",b.state,b.dock,b.province,b.address");
		sql.append(",b.weight,b.box_type,b.price,b.pack_date");
		sql.append(",b.vessel,b.voyage,b.barcode_effective_date,b.earliest_arrival_port_date");
		sql.append(",b.arrival_port,b.bill_of_lading,b.factory_address,b.factory_phone");
		sql.append(",b.ef_yard,b.ef_dock,b.qr_code");
		sql.append(",b.car_team_id,b.car_team,b.car_no,b.driver");
		sql.append(",b.driver_phone,b.driver_freight,b.sys_driver_freight,b.box_num");
		sql.append(",b.box_num_pic,b.sealno,b.sealno_pic,b.pre_entry_pic");
		sql.append(",b.annex,b.up_yard,b.back_yard,b.white_card");
		sql.append(",b.sfile,b.remark,b.feeremark,b.plat_remark");
		sql.append(",b.finance_remark,b.fee_state_s,b.fee_state_f,b.fee_total_s");
		sql.append(",b.fee_total_f,b.factory_address_json");
		sql.append(",b.salesmanId,b.salesman,b.operaterId");
		sql.append(",b.operater,b.create_time,b.create_user,b.update_time");
		sql.append(",b.update_user");
        sql.append(",suser.username createName ");
        sql.append(" from chf_bill_examine b ");
        sql.append(" inner join sys_user suser on suser.user_id=b.create_user ");
        sql.append(" where b.deleted=0 and b.bill_id=:bill_id ");
        map.put("bill_id", billExamine.getBillId());
    	if(Utils.isNotEmpty(billExamine)){
//			if(Utils.isNotEmpty(billExamine.getName())){
//				sql.append(" and instr(b.name,:name)>0 ");
//				map.put("name", billExamine.getName());
//			}
			if(Utils.isNotEmpty(billExamine.getSort())&&Utils.isNotEmpty(billExamine.getOrder())){
                sql.append(" order by b."+billExamine.getSort()+" "+billExamine.getOrder());
            } else {
                sql.append(" order by b.create_time desc");
            }
		}
		return jsonResult(getPageQueryList(page, sql.toString(), map, rm));
	}

	@Override
	public List<BillExamine> list(BillExamine billExamine, User loginUser) {
		Map<String, String> map  = new HashMap<String, String>();
		RowMapper<BillExamine> rm = new BeanPropertyRowMapper<BillExamine>(BillExamine.class);
        StringBuffer sql = new StringBuffer("select b.id,b.organization_id,b.bill_id,b.oceanId");
        sql.append(",b.customer_id,b.customer,b.contacts,b.contacts_phone");
		sql.append(",b.state,b.dock,b.province,b.address");
		sql.append(",b.weight,b.box_type,b.price,b.pack_date");
		sql.append(",b.vessel,b.voyage,b.barcode_effective_date,b.earliest_arrival_port_date");
		sql.append(",b.arrival_port,b.bill_of_lading,b.factory_address,b.factory_phone");
		sql.append(",b.ef_yard,b.ef_dock,b.qr_code");
		sql.append(",b.car_team_id,b.car_team,b.car_no,b.driver");
		sql.append(",b.driver_phone,b.driver_freight,b.sys_driver_freight,b.box_num");
		sql.append(",b.box_num_pic,b.sealno,b.sealno_pic,b.pre_entry_pic");
		sql.append(",b.annex,b.up_yard,b.back_yard,b.white_card");
		sql.append(",b.sfile,b.remark,b.feeremark,b.plat_remark");
		sql.append(",b.finance_remark,b.fee_state_s,b.fee_state_f,b.fee_total_s");
		sql.append(",b.fee_total_f,b.factory_address_json");
		sql.append(",b.salesmanId,b.salesman,b.operaterId");
		sql.append(",b.operater,b.create_time,b.create_user,b.update_time");
		sql.append(",b.update_user");
        sql.append(",suser.username createName ");
        sql.append(" from chf_bill_examine b ");
        sql.append(" inner join sys_user suser on suser.user_id=b.create_user ");
        sql.append(" where b.deleted=0 and b.bill_id=:bill_id ");
        map.put("bill_id", billExamine.getBillId());
    	if(Utils.isNotEmpty(billExamine)){
//			if(Utils.isNotEmpty(billExamine.getName())){
//				sql.append(" and instr(b.name,:name)>0 ");
//				map.put("name", billExamine.getName());
//			}
            if(Utils.isNotEmpty(billExamine.getSort())&&Utils.isNotEmpty(billExamine.getOrder())){
				sql.append(" order by b."+billExamine.getSort()+" "+billExamine.getOrder());
			} else {
				sql.append(" order by b.create_time desc");
			}
		}
		getMapParameter(sql, map);
		return jdbcTemplate.query(sql.toString(),map, rm);
	}

	@Override
	public BillExamine getById(BillExamine billExamine) {
		RowMapper<BillExamine> rm = new BeanPropertyRowMapper<BillExamine>(BillExamine.class);
		Map<String, String> map  = new HashMap<String, String>();
		StringBuffer sql = new StringBuffer("select b.id,b.organization_id,b.bill_id,b.oceanId");
        sql.append(",b.customer_id,b.customer,b.contacts,b.contacts_phone");
		sql.append(",b.state,b.dock,b.province,b.address");
		sql.append(",b.weight,b.box_type,b.price,b.pack_date");
		sql.append(",b.vessel,b.voyage,b.barcode_effective_date,b.earliest_arrival_port_date");
		sql.append(",b.arrival_port,b.bill_of_lading,b.factory_address,b.factory_phone");
		sql.append(",b.ef_yard,b.ef_dock,b.qr_code");
		sql.append(",b.car_team_id,b.car_team,b.car_no,b.driver");
		sql.append(",b.driver_phone,b.driver_freight,b.sys_driver_freight,b.box_num");
		sql.append(",b.box_num_pic,b.sealno,b.sealno_pic,b.pre_entry_pic");
		sql.append(",b.annex,b.up_yard,b.back_yard,b.white_card");
		sql.append(",b.sfile,b.remark,b.feeremark,b.plat_remark");
		sql.append(",b.finance_remark,b.fee_state_s,b.fee_state_f,b.fee_total_s");
		sql.append(",b.fee_total_f,b.factory_address_json");
		sql.append(",b.salesmanId,b.salesman,b.operaterId");
		sql.append(",b.operater,b.create_time,b.create_user,b.update_time");
		sql.append(",b.update_user");
        sql.append(",suser.username createName ");
        sql.append(" from chf_bill_examine b ");
        sql.append(" inner join sys_user suser on suser.user_id=b.create_user ");
        sql.append(" where b.deleted=0 and b.id=:id ");
		map.put("id", billExamine.getId());
		getMapParameter(sql, map);
		return jdbcTemplate.queryForObject(sql.toString(), map, rm);
	}

	@Override
	public boolean save(BillExamine billExamine, User loginUser) {
		Map<String, String> map  = new HashMap<String, String>();
		StringBuffer sql =new StringBuffer("insert into chf_bill_examine (");
        sql.append("organization_id,bill_id,oceanId,customer_id,customer");
		sql.append(",contacts,contacts_phone,state,dock");
		sql.append(",province,address,weight,box_type");
		sql.append(",price,pack_date,vessel,voyage");
		sql.append(",barcode_effective_date,earliest_arrival_port_date,arrival_port,bill_of_lading");
		sql.append(",factory_address,factory_phone,ef_yard");
		sql.append(",ef_dock,qr_code,car_team_id,car_team");
		sql.append(",car_no,driver,driver_phone,driver_freight");
		sql.append(",sys_driver_freight,box_num,box_num_pic,sealno");
		sql.append(",sealno_pic,pre_entry_pic,annex,up_yard");
		sql.append(",back_yard,white_card,sfile,remark");
		sql.append(",feeremark,plat_remark,finance_remark,fee_state_s");
		sql.append(",fee_state_f,fee_total_s,fee_total_f,factory_address_json");
		sql.append(",salesmanId");
		sql.append(",salesman,operaterId,operater,create_user,create_time) values ( ");
        sql.append(":organization_id,:bill_id,:oceanId,:customer_id,:customer");
		sql.append(",:contacts,:contacts_phone,:state,:dock");
		sql.append(",:province,:address,:weight,:box_type");
		sql.append(",:price,:pack_date,:vessel,:voyage");
		sql.append(",:barcode_effective_date,:earliest_arrival_port_date,:arrival_port,:bill_of_lading");
		sql.append(",:factory_address,:factory_phone,:ef_yard");
		sql.append(",:ef_dock,:qr_code,:car_team_id,:car_team");
		sql.append(",:car_no,:driver,:driver_phone,:driver_freight");
		sql.append(",:sys_driver_freight,:box_num,:box_num_pic,:sealno");
		sql.append(",:sealno_pic,:pre_entry_pic,:annex,:up_yard");
		sql.append(",:back_yard,:white_card,:sfile,:remark");
		sql.append(",:feeremark,:plat_remark,:finance_remark,:fee_state_s");
		sql.append(",:fee_state_f,:fee_total_s,:fee_total_f,:factory_address_json");
		sql.append(",:salesmanId");
		sql.append(",:salesman,:operaterId,:operater,:create_user,now())");
        map.put("organization_id", loginUser.getOrganizationId() + "");
        map.put("bill_id", billExamine.getBillId());
        map.put("oceanId", billExamine.getOceanid());
        map.put("customer_id", billExamine.getCustomerId()==null?null:billExamine.getCustomerId()+"");
        map.put("customer", billExamine.getCustomer());
        map.put("contacts", billExamine.getContacts());
        map.put("contacts_phone", billExamine.getContactsPhone());
        map.put("state", billExamine.getState());
        map.put("dock", billExamine.getDock());
        map.put("province", billExamine.getProvince());
        map.put("address", billExamine.getAddress());
        map.put("weight", billExamine.getWeight());
        map.put("box_type", billExamine.getBoxType());
        map.put("price", billExamine.getPrice());
        map.put("pack_date", billExamine.getPackDate());
        map.put("vessel", billExamine.getVessel());
        map.put("voyage", billExamine.getVoyage());
        map.put("barcode_effective_date", billExamine.getBarcodeEffectiveDate());
        map.put("earliest_arrival_port_date", billExamine.getEarliestArrivalPortDate());
        map.put("arrival_port", billExamine.getArrivalPort());
        map.put("bill_of_lading", billExamine.getBillOfLading());
        map.put("factory_address", billExamine.getFactoryAddress());
        map.put("factory_phone", billExamine.getFactoryPhone());
        map.put("ef_yard", billExamine.getEfYard());
        map.put("ef_dock", billExamine.getEfDock());
        map.put("qr_code", billExamine.getQrCode());
        map.put("car_team_id", billExamine.getCarTeamId());
        map.put("car_team", billExamine.getCarTeam());
        map.put("car_no", billExamine.getCarNo());
        map.put("driver", billExamine.getDriver());
        map.put("driver_phone", billExamine.getDriverPhone());
        map.put("driver_freight", billExamine.getDriverFreight());
        map.put("sys_driver_freight", billExamine.getSysDriverFreight());
        map.put("box_num", billExamine.getBoxNum());
        map.put("box_num_pic", billExamine.getBoxNumPic());
        map.put("sealno", billExamine.getSealno());
        map.put("sealno_pic", billExamine.getSealnoPic());
        map.put("pre_entry_pic", billExamine.getPreEntryPic());
        map.put("annex", billExamine.getAnnex());
        map.put("up_yard", billExamine.getUpYard());
        map.put("back_yard", billExamine.getBackYard());
        map.put("white_card", billExamine.getWhiteCard());
        map.put("sfile", billExamine.getSfile());
        map.put("remark", billExamine.getRemark());
        map.put("feeremark", billExamine.getFeeremark());
        map.put("plat_remark", billExamine.getPlatRemark());
        map.put("finance_remark", billExamine.getFinanceRemark());
        map.put("fee_state_s", billExamine.getFeeStateS());
        map.put("fee_state_f", billExamine.getFeeStateF());
        map.put("fee_total_s", billExamine.getFeeTotalS());
        map.put("fee_total_f", billExamine.getFeeTotalF());
        map.put("factory_address_json", billExamine.getFactoryAddressJson());
        map.put("salesmanId", billExamine.getSalesmanid()==null?null:billExamine.getSalesmanid()+"");
        map.put("salesman", billExamine.getSalesman());
        map.put("operaterId", billExamine.getOperaterid()==null?null:billExamine.getOperaterid()+"");
        map.put("operater", billExamine.getOperater());
		map.put("create_user", loginUser.getUserId() + "");
		getMapParameter(sql, map);
		int count = jdbcTemplate.update(sql.toString(), map);
		return count > 0;
	}

	@Override
	public boolean save(Bill billExamine, User loginUser) {
		Map<String, String> map  = new HashMap<String, String>();
		StringBuffer sql =new StringBuffer("insert into chf_bill_examine (");
        sql.append("organization_id,bill_id,oceanId,customer_id,customer");
		sql.append(",contacts,contacts_phone,state,dock");
		sql.append(",province,address,weight,box_type");
		sql.append(",price,pack_date,vessel,voyage");
		sql.append(",barcode_effective_date,earliest_arrival_port_date,arrival_port,bill_of_lading");
		sql.append(",factory_address,factory_phone,ef_yard");
		sql.append(",ef_dock,qr_code,car_team_id,car_team");
		sql.append(",car_no,driver,driver_phone,driver_freight");
		sql.append(",sys_driver_freight,box_num,box_num_pic,sealno");
		sql.append(",sealno_pic,pre_entry_pic,annex,up_yard");
		sql.append(",back_yard,white_card,sfile,remark");
		sql.append(",feeremark,plat_remark,finance_remark,fee_state_s");
		sql.append(",fee_state_f,fee_total_s,fee_total_f,factory_address_json");
		sql.append(",salesmanId");
		sql.append(",salesman,operaterId,operater,create_user,create_time) values ( ");
        sql.append(":organization_id,:bill_id,:oceanId,:customer_id,:customer");
		sql.append(",:contacts,:contacts_phone,:state,:dock");
		sql.append(",:province,:address,:weight,:box_type");
		sql.append(",:price,:pack_date,:vessel,:voyage");
		sql.append(",:barcode_effective_date,:earliest_arrival_port_date,:arrival_port,:bill_of_lading");
		sql.append(",:factory_address,:factory_phone,:ef_yard");
		sql.append(",:ef_dock,:qr_code,:car_team_id,:car_team");
		sql.append(",:car_no,:driver,:driver_phone,:driver_freight");
		sql.append(",:sys_driver_freight,:box_num,:box_num_pic,:sealno");
		sql.append(",:sealno_pic,:pre_entry_pic,:annex,:up_yard");
		sql.append(",:back_yard,:white_card,:sfile,:remark");
		sql.append(",:feeremark,:plat_remark,:finance_remark,:fee_state_s");
		sql.append(",:fee_state_f,:fee_total_s,:fee_total_f,:factory_address_json");
		sql.append(",:salesmanId");
		sql.append(",:salesman,:operaterId,:operater,:create_user,now())");
        map.put("organization_id", loginUser.getOrganizationId() + "");
        map.put("bill_id", billExamine.getBillId());
        map.put("oceanId", billExamine.getOceanId());
        map.put("customer_id", billExamine.getCustomerId()==null?null:billExamine.getCustomerId()+"");
        map.put("customer", billExamine.getCustomer());
        map.put("contacts", billExamine.getContacts());
        map.put("contacts_phone", billExamine.getContactsPhone());
        map.put("state", billExamine.getState());
        map.put("dock", billExamine.getDock());
        map.put("province", billExamine.getProvince());
        map.put("address", billExamine.getAddress());
        map.put("weight", billExamine.getWeight());
        map.put("box_type", billExamine.getBoxType());
        map.put("price", billExamine.getPrice());
        map.put("pack_date", billExamine.getPackDate());
        map.put("vessel", billExamine.getVessel());
        map.put("voyage", billExamine.getVoyage());
        map.put("barcode_effective_date", billExamine.getBarcodeEffectiveDate());
        map.put("earliest_arrival_port_date", billExamine.getEarliestArrivalPortDate());
        map.put("arrival_port", billExamine.getArrivalPort());
        map.put("bill_of_lading", billExamine.getBillOfLading());
        map.put("factory_address", billExamine.getFactoryAddress());
        map.put("factory_phone", billExamine.getFactoryPhone());
        map.put("ef_yard", billExamine.getEfYard());
        map.put("ef_dock", billExamine.getEfDock());
        map.put("qr_code", billExamine.getQrCode());
        map.put("car_team_id", billExamine.getCarTeamId());
        map.put("car_team", billExamine.getCarTeam());
        map.put("car_no", billExamine.getCarNo());
        map.put("driver", billExamine.getDriver());
        map.put("driver_phone", billExamine.getDriverPhone());
        map.put("driver_freight", billExamine.getDriverFreight());
        map.put("sys_driver_freight", billExamine.getSysDriverFreight());
        map.put("box_num", billExamine.getBoxNum());
        map.put("box_num_pic", billExamine.getBoxNumPic());
        map.put("sealno", billExamine.getSealno());
        map.put("sealno_pic", billExamine.getSealnoPic());
        map.put("pre_entry_pic", billExamine.getPreEntryPic());
        map.put("annex", billExamine.getAnnex());
        map.put("up_yard", billExamine.getUpYard());
        map.put("back_yard", billExamine.getBackYard());
        map.put("white_card", billExamine.getWhiteCard());
        map.put("sfile", billExamine.getSfile());
        map.put("remark", billExamine.getRemark());
        map.put("feeremark", billExamine.getFeeRemark());
        map.put("plat_remark", billExamine.getPlatRemark());
        map.put("finance_remark", billExamine.getFinanceRemark());
        map.put("fee_state_s", billExamine.getFeeStateS());
        map.put("fee_state_f", billExamine.getFeeStateF());
        map.put("fee_total_s", billExamine.getFeeTotalS());
        map.put("fee_total_f", billExamine.getFeeTotalF());
        map.put("factory_address_json", billExamine.getFactoryAddressJson());
        map.put("salesmanId", billExamine.getSalesmanId()==null?null:billExamine.getSalesmanId()+"");
        map.put("salesman", billExamine.getSalesman());
        map.put("operaterId", billExamine.getOperaterId()==null?null:billExamine.getOperaterId()+"");
        map.put("operater", billExamine.getOperater());
		map.put("create_user", loginUser.getUserId() + "");
		getMapParameter(sql, map);
		int count = jdbcTemplate.update(sql.toString(), map);
		return count > 0;
	}

	@Override
	public boolean update(BillExamine billExamine, User loginUser) {
		Map<String, String> map  = new HashMap<String, String>();
		StringBuffer sql =new StringBuffer("update chf_bill_examine set ");
        sql.append("bill_id=:bill_id,oceanId=:oceanId,customer_id=:customer_id,customer=:customer ");
		sql.append(",contacts=:contacts,contacts_phone=:contacts_phone,state=:state ");
		sql.append(",dock=:dock,province=:province,address=:address ");
		sql.append(",weight=:weight,box_type=:box_type,price=:price ");
		sql.append(",pack_date=:pack_date,vessel=:vessel,voyage=:voyage ");
		sql.append(",barcode_effective_date=:barcode_effective_date,earliest_arrival_port_date=:earliest_arrival_port_date,arrival_port=:arrival_port ");
		sql.append(",bill_of_lading=:bill_of_lading,factory_address=:factory_address,factory_phone=:factory_phone ");
		sql.append(",ef_yard=:ef_yard,ef_dock=:ef_dock ");
		sql.append(",qr_code=:qr_code,car_team_id=:car_team_id,car_team=:car_team ");
		sql.append(",car_no=:car_no,driver=:driver,driver_phone=:driver_phone ");
		sql.append(",driver_freight=:driver_freight,sys_driver_freight=:sys_driver_freight,box_num=:box_num ");
		sql.append(",box_num_pic=:box_num_pic,sealno=:sealno,sealno_pic=:sealno_pic ");
		sql.append(",pre_entry_pic=:pre_entry_pic,annex=:annex,up_yard=:up_yard ");
		sql.append(",back_yard=:back_yard,white_card=:white_card,sfile=:sfile ");
		sql.append(",remark=:remark,feeremark=:feeremark,plat_remark=:plat_remark ");
		sql.append(",finance_remark=:finance_remark,fee_state_s=:fee_state_s,fee_state_f=:fee_state_f ");
		sql.append(",fee_total_s=:fee_total_s,fee_total_f=:fee_total_f,factory_address_json=:factory_address_json ");
		sql.append(",salesmanId=:salesmanId,salesman=:salesman,operaterId=:operaterId ");
		sql.append(",operater=:operater,update_time=now(),update_user=:update_user where id=:id ");
        map.put("bill_id", billExamine.getBillId());
        map.put("oceanId", billExamine.getOceanid());
        map.put("customer_id", billExamine.getCustomerId()==null?null:billExamine.getCustomerId()+"");
        map.put("customer", billExamine.getCustomer());
        map.put("contacts", billExamine.getContacts());
        map.put("contacts_phone", billExamine.getContactsPhone());
        map.put("state", billExamine.getState());
        map.put("dock", billExamine.getDock());
        map.put("province", billExamine.getProvince());
        map.put("address", billExamine.getAddress());
        map.put("weight", billExamine.getWeight());
        map.put("box_type", billExamine.getBoxType());
        map.put("price", billExamine.getPrice());
        map.put("pack_date", billExamine.getPackDate());
        map.put("vessel", billExamine.getVessel());
        map.put("voyage", billExamine.getVoyage());
        map.put("barcode_effective_date", billExamine.getBarcodeEffectiveDate());
        map.put("earliest_arrival_port_date", billExamine.getEarliestArrivalPortDate());
        map.put("arrival_port", billExamine.getArrivalPort());
        map.put("bill_of_lading", billExamine.getBillOfLading());
        map.put("factory_address", billExamine.getFactoryAddress());
        map.put("factory_phone", billExamine.getFactoryPhone());
        map.put("ef_yard", billExamine.getEfYard());
        map.put("ef_dock", billExamine.getEfDock());
        map.put("qr_code", billExamine.getQrCode());
        map.put("car_team_id", billExamine.getCarTeamId());
        map.put("car_team", billExamine.getCarTeam());
        map.put("car_no", billExamine.getCarNo());
        map.put("driver", billExamine.getDriver());
        map.put("driver_phone", billExamine.getDriverPhone());
        map.put("driver_freight", billExamine.getDriverFreight());
        map.put("sys_driver_freight", billExamine.getSysDriverFreight());
        map.put("box_num", billExamine.getBoxNum());
        map.put("box_num_pic", billExamine.getBoxNumPic());
        map.put("sealno", billExamine.getSealno());
        map.put("sealno_pic", billExamine.getSealnoPic());
        map.put("pre_entry_pic", billExamine.getPreEntryPic());
        map.put("annex", billExamine.getAnnex());
        map.put("up_yard", billExamine.getUpYard());
        map.put("back_yard", billExamine.getBackYard());
        map.put("white_card", billExamine.getWhiteCard());
        map.put("sfile", billExamine.getSfile());
        map.put("remark", billExamine.getRemark());
        map.put("feeremark", billExamine.getFeeremark());
        map.put("plat_remark", billExamine.getPlatRemark());
        map.put("finance_remark", billExamine.getFinanceRemark());
        map.put("fee_state_s", billExamine.getFeeStateS());
        map.put("fee_state_f", billExamine.getFeeStateF());
        map.put("fee_total_s", billExamine.getFeeTotalS());
        map.put("fee_total_f", billExamine.getFeeTotalF());
        map.put("factory_address_json", billExamine.getFactoryAddressJson());
        map.put("salesmanId", billExamine.getSalesmanid()==null?null:billExamine.getSalesmanid()+"");
        map.put("salesman", billExamine.getSalesman());
        map.put("operaterId", billExamine.getOperaterid()==null?null:billExamine.getOperaterid()+"");
        map.put("operater", billExamine.getOperater());
		map.put("update_user", loginUser.getUserId() + "");
		map.put("id", billExamine.getId());
		getMapParameter(sql, map);
		int count = jdbcTemplate.update(sql.toString(), map);
		return count > 0;
	}

	@Override
	public boolean remove(BillExamine billExamine, User loginUser) {
		int count = 0;
		Map<String, String> map = null;
		if(billExamine.getId().length()>0){
			for(String ID : billExamine.getId().split(",")){
				map  = new HashMap<String, String>();
				if(ID==null || ID.equals("")){ break; }
				StringBuffer sql =new StringBuffer("update chf_bill_examine set deleted=1" +
						",update_user=:update_user, update_time=now() "
						+ " where id =:id ");
				map.put("update_user", loginUser.getUserId() + "");
				map.put("id", ID);
				getMapParameter(sql, map);
				count = jdbcTemplate.update(sql.toString(),map);
			}
		}
		return count > 0;
	}
}
